package com.cbl.v.ssczs.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.cbl.v.ssczs.R;


/**
 * 订单取消的时候弹出的dialog
 */
public class CommonDialog extends Dialog implements View.OnClickListener {
	private TextView tvTitle;
	private TextView btnCancel;
	private TextView btnSure;
	private Context context;
	private String data;
	private DialogClickListener dialogClickListener;
	public CommonDialog(Context context) {
		super(context, R.style.dialog);
		this.context = context;
		initData();
		initView();
		initListener();
	}

	public void setData(String data){
		this.data=data;
	}

	private void initData() {

	}

	private void initView() {
		setContentView(R.layout.dialog_common);
		tvTitle = (TextView) findViewById(R.id.edit_write);
		btnCancel = (TextView) findViewById(R.id.text_cancel);
		btnSure = (TextView) findViewById(R.id.text_sure);
	}

	public void setAlert(String alert){
		tvTitle.setText(alert);
	}
	public void setSureButton(String sure){
		btnSure.setText(sure);
	}
	public void setCancelButton(String cancel){
		btnCancel.setText(cancel);
	}

	private void initListener() {
		btnCancel.setOnClickListener(this);
		btnSure.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		if(v==btnSure){
			dialogClickListener.dialogSure(data);
		}else if(v==btnCancel){
			dialogClickListener.dialogCancel();
			dismiss();
		}
	}

	public interface DialogClickListener{
		void dialogSure(String data);
		void dialogCancel();
	}

	public void setDialogClickListener(DialogClickListener dialogClickListener){
		this.dialogClickListener=dialogClickListener;
	}

}
